package com.jx.controller;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.jx.model.Admin;
import com.jx.service.UpdateAdminsService;
import com.jx.servicrimpl.UpdateAdminsServiceImpl;
/**
 * 更新管理员信息
 * @author zzzzzzz
 *
 */
public class UpdateAdminsController extends HttpServlet{
	UpdateAdminsService uas=new UpdateAdminsServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		req.setCharacterEncoding("utf8");
		resp.setCharacterEncoding("utf8");
		//获取前台的数据
		int aid=Integer.parseInt(req.getParameter("aid"));
		String adep=req.getParameter("adep");
		int asalary=Integer.parseInt(req.getParameter("asalary"));
//		实例化管理员
		Admin admin=new Admin(aid,adep,asalary);
		//调用方法
		boolean result=uas.updateAdminService(admin);
		//定义笔，传回数据
		PrintWriter pw=resp.getWriter();
		pw.write(String.valueOf(result));
	}
}
